package concurrent.tool;

import java.util.concurrent.CountDownLatch;

public class CountDownLatchTest {

	public static void main(String[] args) throws InterruptedException {
		
		final CountDownLatch countDown = new CountDownLatch(4);
		
		new Thread(){
			
			@Override
			public void run() {
				
				while(countDown.getCount() > 0){
					
					countDown.countDown();
					System.out.println("倒计时：" + countDown.getCount());
					try {
						Thread.sleep(1000);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				}
			}
		}.start();
		
		System.out.println(countDown.getCount());
		countDown.await();
		System.out.println(countDown.getCount());
	}
}
